package Day015_File类_递归_IO流.demo08_拷贝;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @author zhangyan
 * @date 2020/5/6 16:18
 */
public class Test1 {
    public static void main(String[] args) throws Exception {

        //1.创建字节输入流
        FileInputStream fis = new FileInputStream("Demo02\\aaa\\aaa.png");

        //2.创建字节输出流
        FileOutputStream fos = new FileOutputStream("Demo02\\ccc\\ddd\\aaaCopy.png");

        //3.定义数组,用来存储读取到的字节数据
        byte[] bytes = new byte[8192];
        //3.定义变量 用来存储读取到的字节数据个数
        int len;
        //4.循环读取
        //5.读取同时写出
        while ((len = fis.read(bytes)) != -1) {
            fos.write(bytes,0,len);
        }
        //6.关闭流
        fos.close();
        fis.close();
    }
}

